home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk62 / pipe203 / misc.c < prev    next >
C/C++ Source or Header  |  1995-03-19  |  2KB  |  79 lines

  1.  
  2. /*
  3.  *  MISC.C  - support routines - Phillip Lindsay (C) Commodore 1986
  4.  *  You may freely distribute this source and use it for Amiga Development -
  5.  *  as long as the Copyright notice is left intact.
  6.  *
  7.  * 30-SEP-86
  8.  *
  9.  *  major modifications by Matthew Dillon for my PIPE: and other devices,
  10.  *  but basic theorem still Phil's.
  11.  */
  12.  
  13. #include <exec/types.h>
  14. #include <exec/nodes.h>
  15. #include <exec/lists.h>
  16. #include <exec/ports.h>
  17. #include <libraries/dos.h>
  18. #include <libraries/dosextens.h>
  19. #include <local/typedefs.h>
  20.  
  21. extern void returnpkt();
  22.  
  23. void
  24. returnpktplain(packet, myproc)
  25. struct DosPacket *packet;
  26. struct Process *myproc;
  27. {
  28.     returnpkt(packet, myproc, packet->dp_Res1, packet->dp_Res2);
  29. }
  30.  
  31.  
  32. void
  33. returnpkt(packet, myproc, res1, res2)
  34. register struct DosPacket *packet;
  35. struct Process *myproc;
  36. long res1, res2;
  37. {
  38.     register struct Message *mess;
  39.     register struct MsgPort *replyport;
  40.  
  41.     packet->dp_Res1         = res1;
  42.     packet->dp_Res2         = res2;
  43.     replyport             = packet->dp_Port;
  44.     mess             = packet->dp_Link;
  45.     packet->dp_Port         = &myproc->pr_MsgPort;
  46.     mess->mn_Node.ln_Name    = (char *)packet;
  47.     mess->mn_Node.ln_Succ    = NULL;
  48.     mess->mn_Node.ln_Pred    = NULL;
  49.     PutMsg(replyport, mess);
  50. }
  51.  
  52.  
  53. /*
  54.  * taskwait() ... Waits for a message to arrive at your port and
  55.  *   extracts the packet address which is returned to you.
  56.  */
  57.  
  58. struct DosPacket *
  59. taskwait(myproc)
  60. struct Process *myproc;
  61. {
  62.     register struct MsgPort *myport;
  63.     register struct Message *mymess;
  64.  
  65.     myport = &myproc->pr_MsgPort;
  66.     WaitPort(myport);
  67.     mymess = (struct Message *)GetMsg(myport);
  68.     return((struct DosPacket *)mymess->mn_Node.ln_Name);
  69. }
  70.  
  71. taskpktrdy(myproc)
  72. struct Process *myproc;
  73. {
  74.     if (((MNODE *)myproc->pr_MsgPort.mp_MsgList.lh_Head)->mln_Succ == NULL)
  75.     return(0);
  76.     return(1);
  77. }
  78.  
  79.